/**
 * 功能描述
 */

define(function(require, exports, module) {
	module.exports = {
		settleDataOne: function(data, widget,disabled){
			widget.set("roomPerData", data);
			return [{
					key: "room",
					project: "住宿费",
					money: parseFloat(data.checkOutSettlement.room).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: false
				},{
					key: "roomConsumption",
					project: "房间消费",
					money: parseFloat(data.roomConsumption).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: true
				},{
					key: "damages",
					project: "赔偿费",
					money: parseFloat(data.damagesConsumption).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: true
				},{
					key: "electric",
					project: "电费",
					money: parseFloat(data.checkOutSettlement.electric).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: true
				},{
					key: "electricOther",
					project: "电费其他",
					money: parseFloat(data.checkOutSettlement.electricOther).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "coldWater",
					project: "冷水费",
					money: parseFloat(data.checkOutSettlement.coldWater).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: true
				},{
					key: "hotWater",
					project: "热水费",
					money: parseFloat(data.checkOutSettlement.hotWater).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: true
				},{
					key: "waterOther",
					project: "水费其他",
					money: parseFloat(data.checkOutSettlement.waterOther).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "food",
					project: "餐饮费",
					money: parseFloat(data.checkOutSettlement.food).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "telephone",
					project: "电话费",
					money: parseFloat(data.checkOutSettlement.telephone).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "nurse",
					project: "护理费",
					money: parseFloat(data.checkOutSettlement.nurse).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "health",
					project: "康乐费",
					money: parseFloat(data.checkOutSettlement.health).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "healthOther",
					project: "康乐费其他",
					money: parseFloat(data.checkOutSettlement.healthOther).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "property",
					project: "物业费",
					money: parseFloat(data.checkOutSettlement.property).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "holiday",
					project: "节假日费用",
					money: parseFloat(data.checkOutSettlement.holiday).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "traffic",
					project: "大交通往返费用",
					money: parseFloat(data.checkOutSettlement.traffic).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "pickUp",
					project: "接送往返费用",
					money: parseFloat(data.checkOutSettlement.pickUp).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "manager",
					project: "管理费",
					money: parseFloat(data.checkOutSettlement.manager).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "other",
					project: "其他",
					money: parseFloat(data.checkOutSettlement.other).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "sum",
					project: "收费合计",
					money: parseFloat(data.checkOutSettlement.sum).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: false
				}];
		},
		settleDataTwo: function(data, widget,disabled){
			return [{
					key: "payable",
					project: "预收款",
					money: parseFloat(data.payable).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: false
				},{
					key: "bedSubsidy",
					project: "床位费抵扣",
					money: parseFloat(data.checkOutSettlement.bedSubsidy).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: false
				},{
					key: "expense",
					project: "会员证抵扣",
					money: parseFloat(data.checkOutSettlement.expense).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "coupon",
					project: "福利消费券抵扣",
					money: parseFloat(data.checkOutSettlement.coupon).toFixed(2),
					description: "",
					disabled: disabled,
					showOperate: false
				},{
					key: "balance",
					project: "结算金额",
					money: parseFloat(data.checkOutSettlement.balance).toFixed(2),
					description: "计算得出，不可编辑",
					disabled: true,
					showOperate: false
				}];
		},
		printData: function(widget){
			var detailForm = widget.get("detailForm");
			var form = widget.get("form");
			var data = "";	//拼接打印字符串
			data += "name="+detailForm.getValue("name");
			data += "&idNumber="+detailForm.getValue("idNumber");
			data += "&contractNumber="+detailForm.getValue("contractNumber");
			data += "&checkInDate="+moment(detailForm.getValue("checkInDate")).format("YYYY-MM-DD");
			data += "&checkOutDate="+moment(detailForm.getValue("checkOutDate")).format("YYYY-MM-DD");
			data += "&liveDays="+detailForm.getValue("liveDays");
			data += "&settlementDate="+moment(form.getValue("statementDate")).format("YYYY-MM-DD");
			data += "&operatorName="+form.getValue("operatorName");
			data += "&roomCode="+detailForm.getValue("roomCode");
			data += "&roomType="+detailForm.getValue("roomType");
			var gridData = [];
			$(".J-detailForm span").each(function(){
				gridData.push({
					project: $(this).attr("id"),
					money:parseFloat($(this).text())
				})
            });
			$(".J-detailForm input").each(function(){
				gridData.push({
					project: $(this).attr("id"),
					money:parseFloat($(this).val())
				})
            });
			var settleDataOne = widget.get("settleEditGridOne").getData();
			var settleData = settleDataOne.concat(widget.get("settleEditGridTwo").getData());
			
			var moneyList=[];
			for(var i = 0; i < settleData.length; i++){
				for(var j = 0; j < gridData.length; j++){
					if(gridData[j].project == settleData[i].key){
						settleData[i].money = parseFloat(gridData[j].money).toFixed(2);
						break;
					}
				}
				//data += "&"+settleData[i].project+"="+settleData[i].money;
				moneyList.push({
					project: settleData[i].project,
					money: settleData[i].money,
					remak: settleData[i].description
				})
			}
			data += "&moneyList="+JSON.stringify(moneyList);
			return data;
		}
	}
});
